<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>layout 后台大布局 - Layui</title>
<link rel="stylesheet" href="/layui-v2.0.1/layui/css/layui.css">
<link rel="stylesheet" href="/css/admin.css">

</head>
<body>

<div class="layui-layout layui-layout-admin">
    @include('admin.header')
  
  <div class="layui-side layui-bg-black">
    <div class="layui-side-scroll">
      <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
       @include('admin.leftadmin')
    </div>
  </div>
  
  <div class="layui-body">
    <!-- 内容主体区域 -->
    <div style="padding: 15px;">内容主体区域</div>

<!--  <table class="layui-table" lay-data="{height:313, url:'getdata'}">
  <thead>
    <tr>
      <th lay-data="{field:'id', width:80, sort: true}">ID</th>
      <th lay-data="{field:'lien', width:80}">顺位</th>
      <th lay-data="{field:'lien_number', width:80,}">顺位值</th>
      <th lay-data="{field:'explanination', width:80}">城市</th>
      <th lay-data="{fixed: 'right', width:150, align:'center', toolbar: '#barDemo'}"></th>  
    </tr>
  </thead>
 </table> 
 <table class="layui-table" id="test" lay-filter="test">
 </table> -->
  <table class="layui-table" lay-data="{ height:500, url:'getdata', page:true, id:'test',limit:10}">
   <thead>
    <tr>
      <th lay-data="{checkbox:true, fixed: true}"></th>
      <th lay-data="{field:'id', width:180, sort: true, fixed: true}">ID</th>
      <th lay-data="{field:'username', width:180}">名称</th>
      <th lay-data="{field:'password', width:180}">密码</th>
      <th lay-data="{field:'addtime', width:850}">创建时间</th>
      
      <th lay-data="{fixed: 'right', width:260, align:'center', toolbar: '#barDemo'}"></th>
    </tr>
   </thead>
  </table>
   <script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-mini" lay-event="detail">查看</a>
    <a class="layui-btn layui-btn-mini" lay-event="edit">修改</a>
    <a class="layui-btn layui-btn-danger layui-btn-mini dele" lay-event="del">删除</a>
   </script>

    
  </div>
  <div class="layui-footer">
    <!-- 底部固定区域 -->
    © layui.com - 底部固定区域
  </div>
</div>
<script src="/layui-v2.0.1/layui/layui.js"></script>

<script>
layui.use(['table','jquery'],function(){
  var table = layui.table;
  var $ = layui.jquery;
  table.on('tool(test)', function(obj){ //注：tool是工具条事件名，test是table原始容器的属性 lay-filter="对应的值"
  var data = obj.data; //获得当前行数据
  var layEvent = obj.event; //获得 lay-event 对应的值
  var tr = obj.tr; //获得当前行 tr 的DOM对象
  var id=data['id'];

  if(layEvent === 'detail'){ //查看
    //do somehing
    layer.open({
    type: 2,
    title: '详情',
    maxmin: true,
    shadeClose: true, //点击遮罩关闭层
    area : ['800px' , '520px'],
    shade: [0.65],
    content: 'adminuser?id='+id,
    // end : function(){
    //   location.reload();
    // }
    })


  } else if(layEvent === 'del'){ //删除
    layer.confirm('真的删除行么', function(index){
      obj.del(); //删除对应行（tr）的DOM结构
      layer.close(index);
        $.ajax({
        url:'dele',
        type:'post',
        data:{'id':id},
        dataType:'json',
        success:function(d){
          if(d.code==200){
            layer.msg(d.msg, {
            icon: 1,
            time: 1000 //1秒关闭（如果不配置，默认是3秒）
          });  
          }else{
            layer.msg(d.msg);
          }
         }
        })

      //向服务端发送删除指令
    });
  } else if(layEvent === 'edit'){ //编辑
    //do something
    layer.open({
    type: 2,
    title: '修改',
    maxmin: true,
    shadeClose: true, //点击遮罩关闭层
    area : ['550px' , '520px'],
    shade: [0.65],
    content: 'changeadmin?id='+id,
    end : function(){
      location.reload();
    }
    })
    
  }
});


});

</script>
</body>
</html>
<script>
  layui.use(['element',], function(){
  var element = layui.element;
  
});

</script>





